package com.example.temp;


import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;

public class Test21 {
    private static String INJECTION_TOKEN = "http://125.35.5.127/mobile/cordova/";
    private static String url = "http://125.35.5.127/mobile/cordova/hahah/123";
    public static void main(String[] args) {
        String assetPath = url.substring(url.indexOf(INJECTION_TOKEN) + INJECTION_TOKEN.length());
        System.out.println(assetPath);
    }

    /**
     * 从上往下打印出二叉树的每个节点，同层节点从左至右打印。
     */
    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }
    }

    public class Solution {

        public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
            ArrayList<Integer> arrayList = new ArrayList<>();
            if (root==null)return arrayList;

            Deque<TreeNode> deque = new LinkedList<>();
            //linkedList的add是添加到链表尾部 push相当于addFirst()t
            deque.add(root);

            while (!deque.isEmpty()){
                TreeNode temp = deque.pop();
                arrayList.add(temp.val);
                //左右两个节点按顺序加入队列中
                if (temp.left!=null){
                    deque.add(temp.left);
                }

                if (temp.right!=null){
                    deque.add(temp.right);
                }
            //遍历完毕左右节点都为空
            }
            return arrayList;

        }
    }
}
